<?php
	global $db_connection;
	
	function getProfile($userId)
	{
		$sql = "SELECT * FROM profile WHERE UserId = '".trim($userId)."'";
		$result = mysqli_query(getDB(),$sql);
		//var_dump($result);
		if(mysqli_num_rows($result)!=0) return false;	
		//while($row = mysqli_fetch_assoc($result))
		//{
		//	return $row;
		//}			
	}
	function getImage($idEntries)
	{
		$sql = "SELECT * FROM image WHERE IdEntries = '".trim($idEntries)."'";
		$result = mysqli_query($sql, $db_connection);
		if(!mysqli_num_rows($result)) return false;
		while($row = mysqli_fetch_assoc($result))
		{
			return $row;
		}		
	}
	function getComment($idEntries, $userId)
	{
		$sql = "SELECT * FROM comment WHERE IdEntries = '".trim($idEntries)."' AND UserId = '".trim($userId)."'" ;
		$result = mysqli_query($sql, $db_connection);
		if(!mysqli_num_rows($result)) return false;
		while($row = mysqli_fetch_assoc($result))
		{
			$list[] = $row;
		}	
		return $list;
	}
	function getCategories($idEntries)
	{
		$sql = "SELECT * FROM categories WHERE IdEntries = '".trim($idEntries)."'";
		$result = mysqli_query($sql, $db_connection);
		if(!mysqli_num_rows($result)) return false;
		while($row = mysqli_fetch_assoc($result))
		{
			return $row;
		}		
	}
	function getCount($userId)
	{
		$sql = "SELECT * FROM count WHERE UserId = '".trim($userId)."'";
		$result = mysqli_query($sql, $db_connection);
		if(!mysqli_num_rows($result)) return false;
		while($row = mysqli_fetch_assoc($result))
		{
			return $row;
		}
	}
	function getEntries($userId)
	{
		$sql = "SELECT * FROM entries WHERE UserId = '".trim($userId)."'";
		$result = mysqli_query($sql, $db_connection);
		if(!mysqli_num_rows($result)) return false;
		while($row = mysqli_fetch_assoc($result))
		{
			return $row;
		}
	}
